package cn.itcast.demo.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 虎哥
 */
@Controller
public class HelloController {

    @GetMapping("hello")
    public String hello(Model model){
        model.addAttribute("msg", "thymeleaf");


        List<String> boys = new ArrayList<>();
        boys.add("LiuDeHua");
        boys.add("HuGe");
        boys.add("PengYuYan");
        boys.add("ZhangHuYi");

        model.addAttribute("boys", boys);
        return "hello";
    }


    // 返回的视图名称，需要根据视图解析器，寻找视图：
    // InternalResourceViewResolver
    // prefix: /WEB-INF/views/
    // suffix: .jsp
    // prefix + viewName + suffix
}
